home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fritz: All Fritz
/
All Fritz.zip
/
All Fritz
/
FILES
/
PROGMISC
/
MODULTUB.LZH
/
RANPROC.MOD
< prev
next >
Wrap
Text File
|
1989-01-18
|
1KB
|
65 lines
(* Chapter 15 - Program 4 *)
MODULE RanProc;
FROM InOut IMPORT WriteString, WriteLn;
FROM SYSTEM IMPORT WORD, PROCESS, ADR, SIZE, NEWPROCESS, TRANSFER;
VAR MainOne, ToggleOne, HelloOne : PROCESS;
Space1, Space2 : ARRAY[1..300] OF WORD;
Index : CARDINAL;
PROCEDURE Toggle;
VAR ToggleFactor : CARDINAL;
BEGIN
ToggleFactor := 0;
LOOP
IF ToggleFactor = 1 THEN
ToggleFactor := 0;
WriteString(" odd");
TRANSFER(ToggleOne, HelloOne);
ELSE
ToggleFactor := 1;
WriteString(" even");
TRANSFER(ToggleOne,MainOne);
END;
END;
END Toggle;
PROCEDURE Hello;
BEGIN
LOOP
WriteString(" hello");
TRANSFER(HelloOne,MainOne);
END;
END Hello;
BEGIN (* Main Program *)
NEWPROCESS(Toggle,ADR(Space1),SIZE(Space1),ToggleOne);
NEWPROCESS(Hello,ADR(Space2),SIZE(Space2),HelloOne);
FOR Index := 1 TO 7 DO
WriteString("Start");
TRANSFER(MainOne,ToggleOne);
WriteString(" middle");
TRANSFER(MainOne,HelloOne);
WriteString(" end.");
WriteLn;
END;
END RanProc.
(* Result of execution
Start even middle hello end.
Start odd hello middle hello end.
Start even middle hello end.
Start odd hello middle hello end.
Start even middle hello end.
Start odd hello middle hello end.
Start even middle hello end.
*)